/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.remotecalc;

import com.nico.remotebean.IRemoteBean;
import javax.ejb.Stateless;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author nico
 */

@Stateless
public class CalculatorBean implements ICalculatorBeanRemote{

    @Override
    public double add(double a, double b) {
        return a+b;
    }    
    
    public String getValueCalc()  {
         try {
            InitialContext context = new InitialContext();
            
            String name = "java:global/remoteBean/NewSessionBean!com.nico.remotebean.IRemoteBean";
            
            IRemoteBean bean =
            (IRemoteBean)context.lookup(name);
            
             System.out.println("In Calc Bean: " + bean.getValue());
             
             return bean.getValue();
            
            }
            catch(javax.naming.NoInitialContextException e) {
            e.printStackTrace();
            }
            catch (NamingException e) {
            e.printStackTrace();
        }
         
        return "nix";
    }
}
